package com.auth.manage.user.infra.util;

import lombok.Getter;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;

@Getter
public class BloomUtilsBean {
    private final static String INVITE_CODE = "inviteCode";
    private final static String TELEPHONE = "telephone";

    private final RBloomFilter<String> inviteCodeBloomFilter;
    private final RBloomFilter<String> telephoneBloomFilter;

    public BloomUtilsBean(RedissonClient redissonClient){
        inviteCodeBloomFilter = redissonClient.getBloomFilter(INVITE_CODE);
        telephoneBloomFilter = redissonClient.getBloomFilter(TELEPHONE);
    }

    public boolean isTelephoneExist(String telephone){
        return telephoneBloomFilter.contains(telephone);

    }
    public boolean isInviteCodeExist(String inviteCode){
        return telephoneBloomFilter.contains(inviteCode);
    }


}
